
#version 130

uniform vec4 uLightSourcePos[1];
uniform vec4 uLightSourceDif[1];
uniform vec4 uLightSourceAmb[1];

in vec4 vVertex;
in vec4 vColor;
in vec3 vNormal;
in vec2 vTexCoord;

out vec4 fColor;
out vec3 fNormal;
out vec2 fTexCoord;
out vec3 fVertPos;

void main()
{
	vec4 uLightSourcePos2[1];
	vec4 uLightSourceDif2[1];
	vec4 uLightSourceAmb2[1];
	uLightSourcePos2[0] = vec4(0,10,0,0);
	uLightSourceDif2[0] = vec4(0.5, 0.5, 0.5, 1);
	uLightSourceAmb2[0] = vec4(0.3, 0.3, 0.3, 1);
	vec4 vColor2 = vec4(0.8f, 0.2f, 0.1f, 1.0f);

	vec3 normal, lightDir;
	vec4 diffuseColor;
	float intensity;
	
	normal = normalize(vNormal);

	lightDir = normalize(vec3(uLightSourcePos2[0]));
	intensity = max(dot(normal, lightDir), 0.0);

	diffuseColor = intensity * uLightSourceDif2[0];

	gl_Position = gl_ModelViewProjectionMatrix * vVertex;
	
	fColor = diffuseColor + uLightSourceAmb2[0];
	fNormal = normal;
	fTexCoord = vTexCoord;
	fVertPos = vec3(gl_Position);
}
